/**
 * 
 */
package edu.winona.csclub.testing.utils;

import java.util.Iterator;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class IterableNodeList implements Iterable<Node>, Iterator<Node> {
	NodeList orig;
	int cur;
	public IterableNodeList(NodeList orig){
		this.orig = orig;
		cur = 0;
	}
	
	/**
	 *  this could be very un thread safe, lets just hope in 
	 *  the case of this program we will never have 2 threads owning 
	 *  this NodeList and tring to iterate it over same time... or BOOM
	 *  
	 *  this could be bad :S
	 */
	public Iterator<Node> iterator() {
		cur=0;
		return this;
	}

	public boolean hasNext() {
		return cur<orig.getLength();
	}

	public Node next() {
		Node o= orig.item(cur);
		cur++;
		return o;
	}

	public void remove() {
				throw new UnsupportedOperationException("nana, no remove for you");	
	}
	
}